/**
 * 
 */
package com.demo2do.strawberry.entity.startup.activity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Type;

import com.alibaba.fastjson.annotation.JSONField;
import com.demo2do.strawberry.entity.investor.Investor;
import com.demo2do.strawberry.entity.startup.Startup;
import com.demo2do.strawberry.entity.user.profile.Profile;

/**
 * @author lute
 *
 */
@Entity
@Table(name = "startup_rating")
public class Rating {
	
	@Id
	@GeneratedValue
	private Long id;
	
	@Column(name = "is_recommend")
	private boolean recommend;
	
	private float star;
	
	@Type(type = "text")
	private String reason;
	
	private Date createTime;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = true)
	private Profile profile;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JSONField(serialize = false)
	private Startup startup;
	
	@Transient
	private Investor investor;
	
	/**
	 * default constructor
	 */
	public Rating() {
		
	}
	
	/**
	 * initialize the rating
	 * 
	 * @param startup
	 * @param profile
	 * @param recommend
	 * @return
	 */
	public Rating initialize(Startup startup, Profile profile, boolean recommend) {
		this.startup = startup;
		this.profile = profile;
		this.recommend = recommend;
		this.createTime = new Date();
		return this;
	}
	
	/**
	 * @param investor
	 * @return
	 */
	public Rating initializeInvestor(Investor investor) {
		this.investor = investor;
		return this;
	}
	
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @return the recommend
	 */
	public boolean isRecommend() {
		return recommend;
	}
	
	/**
	 * @return the star
	 */
	public float getStar() {
		return star;
	}

	/**
	 * @return the reason
	 */
	public String getReason() {
		return reason;
	}
	
	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}
	
	/**
	 * @return the profile
	 */
	public Profile getProfile() {
		return profile;
	}

	/**
	 * @return the startup
	 */
	public Startup getStartup() {
		return startup;
	}
	
	/**
	 * @return the investor
	 */
	public Investor getInvestor() {
		return investor;
	}
	
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @param recommend the recommend to set
	 */
	public void setRecommend(boolean recommend) {
		this.recommend = recommend;
	}

	/**
	 * @param star the star to set
	 */
	public void setStar(float star) {
		this.star = star;
	}
	
	/**
	 * @param reason the reason to set
	 */
	public void setReason(String reason) {
		this.reason = reason;
	}
	
	/**
	 * @param createTime the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	/**
	 * @param profile the profile to set
	 */
	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	/**
	 * @param startup the startup to set
	 */
	public void setStartup(Startup startup) {
		this.startup = startup;
	}
	
	/**
	 * @param investor the investor to set
	 */
	public void setInvestor(Investor investor) {
		this.investor = investor;
	}
	
}
